package com.itheima.manage_system;

import com.itheima.manage_system.domain.Person;

import java.util.ArrayList;
import java.util.Scanner;

public class Start {
    public static void main(String[] args) {
        ArrayList<Person> listTeacher = new ArrayList<>();//老师集合
        ArrayList<Person> listStudent = new ArrayList<>();//学生集合

/*        //初始测试代码
        Person p1 = new Person("001", "杨老师", 50, "光明顶");
        Person p2 = new Person("002", "张老师", 103, "武当山");
        listTeacher.add(p1);
        listTeacher.add(p2);
        Person p3 = new Person("001", "周芷若", 22, "峨眉山");
        Person p4 = new Person("002", "赵敏", 23, "汝阳王府");
        Person p5 = new Person("003", "蛛儿", 21, "牛家村");
        Person p6 = new Person("004", "小昭", 20, "光明顶");
        Person p7 = new Person("005", "小昭", 21, "冰火岛");
        listStudent.add(p3);
        listStudent.add(p4);
        listStudent.add(p5);
        listStudent.add(p6);
        listStudent.add(p7);*/


        Scanner sc = new Scanner(System.in);
        Operate operate = new Operate();
        System.out.println("--------欢迎进入学校人员管理系统--------");
        while (true) {
            System.out.println("1:老师系统\t2:学生系统\t3:退出系统");
            String select = sc.nextLine();
            switch (select) {
                case "1":
//                    System.out.println("老师系统");
                    loopTeacher:
                    while (true) {
                        System.out.println("--------------------------------------------------");
                        System.out.println("1:添加老师\t2:删除老师\t3:修改老师\t4:查询所有老师\t\n5:查询名字\t6:返回上一层\t7:退出");
                        System.out.println("--------------------------------------------------");
                        System.out.println("请选择:");
                        select = sc.nextLine();
                        switch (select) {
                            case "1":
                                operate.addPerson(listTeacher);
                                break;
                            case "2":
                                operate.removePerson(listTeacher);
                                break;
                            case "3":
                                operate.updatePerson(listTeacher);
                                break;
                            case "4":
                                operate.allPerson(listTeacher);
                                break;
                            case "5":
                                operate.sameName(listTeacher);
                                break;
                            case "6":
                                //返回上一层
                                break loopTeacher;
                            case "7":
                                System.out.println("谢谢使用,再见");
                                return;
                            default:
                                System.out.println("输入有误");
                                break;
                        }
                    }
                    break;

                case "2":
//                    System.out.println("学生系统");
                    loopStudent:
                    while (true) {
                        System.out.println("--------------------------------------------------");
                        System.out.println("1:添加学生\t2:删除学生\t3:修改学生\t4:查询所有学生\t\n5:查询名字\t6:返回上一层\t7:退出");
                        System.out.println("--------------------------------------------------");
                        System.out.println("请选择:");
                        select = sc.nextLine();
                        switch (select) {
                            case "1":
                                operate.addPerson(listStudent);
                                break;
                            case "2":
                                operate.removePerson(listStudent);
                                break;
                            case "3":
                                operate.updatePerson(listStudent);
                                break;
                            case "4":
                                operate.allPerson(listStudent);
                                break ;
                            case "5":
                                operate.sameName(listStudent);
                                break;
                            case "6":
                                //返回上一层
                                break loopStudent;
                            case "7":
                                System.out.println("谢谢使用,再见");
                                return;
                            default:
                                System.out.println("输入有误");
                                break;
                        }
                    }
                    break;

                case "3":
                    System.out.println("谢谢使用,再见");
                    return;

                default:
                    System.out.println("输入有误");
                    break;
            }
        }
    }
}
